# https://just.systems/man/zh/
# just --completions zsh > just.zsh 
# just --completions fish > just.fish  
# just --completions fish > ~/.config/fish/completions/just.fish 

set dotenv-load

default: s
# server
s:
    hugo
    hugo server --minify
# production
e:
    hugo serve -e production
# build
p:
    hugo
c:
    bash toot-map.bash
css:
    npx unocss "layouts/**/*.html" -o "static/css/uno.css" --watch
clean:
    rm -rf public
    rm -rf doit-doc
    
artalk-admin:
    #!/bin/bash
    cd kkbt/ReverseProxy
    go run . -r  https://func-aceh-kkbt-tools-irakvvlhcy.cn-hangzhou.fcapp.run 
# DoIt exampleSite
examples:
    #!/bin/bash
    cd themes/DoIt2/
    mv exampleSite/content/posts/theme-documentation-built-in-shortcodes .
    echo -e "theme=\"DoIt\"\nthemesDir = \"../..\"" > exampleSite/config.toml
    hugo server --source=exampleSite
    rm -rf exampleSite/config.toml
    mv theme-documentation-built-in-shortcodes exampleSite/content/posts/

examples-build:
    #!/bin/bash
    rm -rf doit-doc
    cp -r themes/DoIt2/exampleSite kkbt/tem/
    rm -rf kkbt/tem/content/posts/theme-documentation-built-in-shortcodes/
    cp kkbt/doit-doc-tem-config.toml kkbt/tem/config.toml
    cd kkbt/tem/
    hugo --baseURL=/doit-doc/
    cd ../../
    cp -r kkbt/tem/public/ doit-doc
    rm -rf kkbt/tem/

# git submodule update --init --recursive

update-theme:
    #!/bin/bash
    cd themes/DoIt
    git pull
    cd ..
    rm -rf DoIt2
    cp -r DoIt/ DoIt2
    rm -rf DoIt2/.git 
    echo "Fix artalk.js darkMode"
    cd ..
    cp kkbt/patch/artalk.js themes/DoIt2/assets/js/lib/artalk.js 
# list
l:
    just --list 

# hugo new posts/2023/$(date +'%Y-%m-%d').md bash
# hugo new posts/2023/(date +'%Y-%m-%d').md fish
# n:
#     #!/bin/bash
#     hugo new posts/2023/$(date +'%Y-%m-%d').md
n FILENAME:
    #!/bin/bash
    hugo new posts/2024/$(date +'%Y-%m-%d')-{{FILENAME}}.md

# open brower
explorer:
    explorer.exe http://127.0.0.1:1313/
ps:
    python3 -m http.server 8888 

qf-get-token:
    #!/bin/bash
    curl "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=${bd_qianfan_apikey}&client_secret=${bd_qianfan_secertkey}" | jq .access_token
ai:
    #!/home/kkbt/.cargo/bin/nu

################
### 备份微语
w1:
    just kkbt/SOP/work1
    mv kkbt/SOP/Work-01/whispers.min.json content/whispers/
    # kkbt/bin/upgit/upgit kkbt/SOP/Work-01/whispers.tem.json
    mv kkbt/SOP/Work-01/whispers.tem.json ~/.trash
    cd content/whispers/ && python3 ../../kkbt/SOP/Work-01/spilt.py
backup:
    #!/bin/bash
    current_date=$(date +"%Y-%m-%d")
    cd ..
    # zip -r blog_backup_$current_date.zip www.ftls.xyz/ -x "www.ftls.xyz/themes/*" -x "www.ftls.xyz/.git/*" -x "www.ftls.xyz/public/*" -x "www.ftls.xyz/kkbt/backup/*" -x "www.ftls.xyz/node_modules/*"
    7z a blog_backup_$current_date.7z "www.ftls.xyz/" "-xr!themes/" "-xr!.git/" "-xr!public/" "-xr!bin/" "-xr!node_modules/"
    mv  blog_backup_$current_date.7z blog_backup/
    cd blog_backup
    explorer.exe .
#  website link check
check:
    muffet http://127.0.0.1:1313/ > kkbt/check/muffet.log

### Local GTS

gts:
    #!/bin/bash
    cd kkbt/bin/gts/
    ./gotosocial --config-path config.yaml server start

### wenku
wk2:
    luajit kkbt/update.lua
    luajit script/map.lua
wk:
    gl script/kgou.lua
wk3:
    luajit script/kjsu.lua